package com.example.emas_android_demo;

import android.os.Bundle;
import android.view.MenuItem;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.Toolbar;

public class TodoDetailActivity extends AppCompatActivity {

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_todo_detail);

        TextView tvTodoTitle = findViewById(R.id.tvTodoTitle);
        TextView tvTodoDesc = findViewById(R.id.tvTodoDesc);
        TextView tvTodoStatus = findViewById(R.id.tvTodoStatus);
        TextView tvTodoPriority = findViewById(R.id.tvTodoPriority);
        TextView tvTodoExpectTime = findViewById(R.id.tvTodoExpectTime);

        // Get intent data
        String title = getIntent().getStringExtra("TITLE");
        String desc = getIntent().getStringExtra("DESC");
        String status = getIntent().getStringExtra("STATUS");
        String priority = getIntent().getStringExtra("PRIORITY");
        String expectTime = getIntent().getStringExtra("EXPECTTIME");

        tvTodoTitle.setText(title);
        tvTodoDesc.setText("描述：" + desc);
        tvTodoStatus.setText("状态：" + status);
        tvTodoPriority.setText("优先级：" + priority);
        tvTodoExpectTime.setText("期望时间：" + expectTime);


        Toolbar toolbar = findViewById(R.id.toolbar);
        setSupportActionBar(toolbar);

        // 启用返回按钮
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            getSupportActionBar().setDisplayShowHomeEnabled(true);
        }
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        if (item.getItemId() == android.R.id.home) {
            // 返回上一页
            finish();
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

